package com.example.spring.boot.rabbitmq.configure;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DemoReturnedCallback implements RabbitTemplate.ReturnsCallback {


    @Override
    public void returnedMessage(ReturnedMessage returned) {
        String exchange = returned.getExchange();
        Message message = returned.getMessage();
        int replayCode = returned.getReplyCode();
        String replayText = returned.getReplyText();
        String routingKey = returned.getRoutingKey();
        System.out.println("消息消费失败，原因=" + replayText + ",消息内容="
                + new String(message.getBody()));
        //做重试
    }
}
